<template>
    <div class="icons">
        <swiper :options="swiperOption">
            <swiper-slide v-for="(item,index) of page" :key="index">
                <div class="icon" v-for="i of item" :key='i.id'>
                    <div class="icon-img">
                        <img class="img" :src="i.imgUrl" alt="">
                    </div>
                    <p class="icon-content">{{i.desc}}</p>
                </div>
            </swiper-slide>
            <div class="swiper-pagination"  slot="pagination"></div>
        </swiper>
    </div>
</template>
<script>
export default {
  name: 'HomeIcons',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        autoplay: false
      }
    }
  },
  computed: {
    page () {
      let pages = []
      this.list.forEach(function (item, index) {
        var page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>
<style lang="stylus" scoped>
 @import '~styles/varible.styl';
 @import '~styles/mixin.styl';
  .icons>>> .swiper-pagination-bullet-active
    background rgba(0,175,190,.8) !important
  .icons>>>.swiper-container
    margin-top .1rem
    height 0
    padding-bottom 57%
    .swiper-pagination-icon
    .icon
      position relative
      float left
      width 25%
      height 0
      padding-bottom 25%
      .icon-img
        position absolute
        top 0
        left 0
        right 0
        bottom .44rem
        padding .05rem
        .img
          height 100%
          display block
          margin 0 auto
      .icon-content
         position absolute
         left 0
         right 0
         bottom 0
         text-align center
         height .44rem
         font-size .32rem
         line-height .44rem
         color $darkTextColor
         ellipsis()
</style>
